home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / itcl1_31.z / itcl1_31 / tcldev / itcl-1.3 / src / tkAppInit.c < prev   
Encoding:
C/C++ Source or Header  |  1993-10-13  |  3.4 KB  |  112 lines

  1. /* 
  2.  * tkAppInit.c --
  3.  *
  4.  *    Provides a default version of the Tcl_AppInit procedure for
  5.  *    use in wish and similar Tk-based applications.
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * All rights reserved.
  9.  *
  10.  * Permission is hereby granted, without written agreement and without
  11.  * license or royalty fees, to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose, provided that the
  13.  * above copyright notice and the following two paragraphs appear in
  14.  * all copies of this software.
  15.  * 
  16.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20.  *
  21.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26.  */
  27.  
  28. #ifndef lint
  29. static char rcsid[] = "$Header: /user6/ouster/wish/RCS/tkAppInit.c,v 1.8 93/08/26 14:38:24 ouster Exp $ SPRITE (Berkeley)";
  30. #endif /* not lint */
  31.  
  32. #include "tk.h"
  33. #include "itcl.h"
  34.  
  35. /*
  36.  * The following variable is a special hack that allows applications
  37.  * to be linked using the procedure "main" from the Tk library.  The
  38.  * variable generates a reference to "main", which causes main to
  39.  * be brought in from the library (and all of Tk and Tcl with it).
  40.  */
  41.  
  42. extern int main();
  43. int *tclDummyMainPtr = (int *) main;
  44.  
  45. /*
  46.  *----------------------------------------------------------------------
  47.  *
  48.  * Tcl_AppInit --
  49.  *
  50.  *    This procedure performs application-specific initialization.
  51.  *    Most applications, especially those that incorporate additional
  52.  *    packages, will have their own version of this procedure.
  53.  *
  54.  * Results:
  55.  *    Returns a standard Tcl completion code, and leaves an error
  56.  *    message in interp->result if an error occurs.
  57.  *
  58.  * Side effects:
  59.  *    Depends on the startup script.
  60.  *
  61.  *----------------------------------------------------------------------
  62.  */
  63.  
  64. int
  65. Tcl_AppInit(interp)
  66.     Tcl_Interp *interp;        /* Interpreter for application. */
  67. {
  68.     Tk_Window main;
  69.  
  70.     main = Tk_MainWindow(interp);
  71.  
  72.     /*
  73.      * Call the init procedures for included packages.  Each call should
  74.      * look like this:
  75.      *
  76.      * if (Mod_Init(interp) == TCL_ERROR) {
  77.      *     return TCL_ERROR;
  78.      * }
  79.      *
  80.      * where "Mod" is the name of the module.
  81.      */
  82.  
  83.     if (Tcl_Init(interp) == TCL_ERROR) {
  84.     return TCL_ERROR;
  85.     }
  86.     if (Tk_Init(interp) == TCL_ERROR) {
  87.     return TCL_ERROR;
  88.     }
  89.  
  90.     /*
  91.      *  Add [incr Tcl] facilities...
  92.      */
  93.     if (Itcl_Init(interp) == TCL_ERROR) {
  94.         return TCL_ERROR;
  95.     }
  96.  
  97.     /*
  98.      * Call Tcl_CreateCommand for application-specific commands, if
  99.      * they weren't already created by the init procedures called above.
  100.      */
  101.  
  102.     /*
  103.      * Specify a user-specific startup file to invoke if the application
  104.      * is run interactively.  Typically the startup file is "~/.apprc"
  105.      * where "app" is the name of the application.  If this line is deleted
  106.      * then no user-specific startup file will be run under any conditions.
  107.      */
  108.  
  109.     tcl_RcFileName = "~/.wishrc";
  110.     return TCL_OK;
  111. }
  112.